package com.itheima.service;

import com.itheima.domain.Order;
import lombok.extern.slf4j.Slf4j;
import org.apache.rocketmq.spring.annotation.ConsumeMode;
import org.apache.rocketmq.spring.annotation.MessageModel;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.stereotype.Service;

/**
 * @author MI
 * @ClassName SmsService.java
 * @createTime 2021年11月25日 19:31:00
 */
@Slf4j
@Service
@RocketMQMessageListener(consumerGroup = "shop-user",
        topic = "order-topic",
        consumeMode = ConsumeMode.CONCURRENTLY,//消费模式，指定是否顺序消费，CONCURRENTLY(同步，默认)
        messageModel = MessageModel.CLUSTERING//消息模式 BROADCASTING 广播模式,CLUSTERING 集群模式(默认)、集群模式指的是一条消息只能被一个消费者消费
)
public class SmsService implements RocketMQListener<Order> {
    //消费逻辑
    @Override
    public void onMessage(Order message) {
        log.info("接受到一个订单消息{}", message);
    }
}
